<?php
//***************  add by code   ******************
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of article
 *
 * @author Administrator
 */
class article extends CI_Controller {

    private $page_size=10;

    public function __construct() {
        parent::__construct();
        $this->url = $this->uri->segments;
        $this->CI = & get_instance();
    }

    public function detail($id) {
        if($id){
            $this->CI->load->library('a_article');
            $data['article_info'] = $this->CI->a_article->get_article($id);
            $data['article_info']['clicknum'] += 1;
            $this->m_public->editInfo(array('articleid'=>$data['article_info']['articleid']),$data['article_info'],'article');
            $data['parent_info'] = $this->m_public->getRowInfo('class',array('classid'=>$data['article_info']['classid']));
            $data['brother_info'] = $this->m_public->getAllInfo('class',array('parentid'=>$data['parent_info']['parentid']));
            $data['p_parent_info'] = $this->m_public->getRowInfo('class',array('classid'=>$data['parent_info']['parentid']));

            $data['last_article'] = $this->db
                ->query('select * from t_article where articleid<'.$id.' and classid='.$data['article_info']['classid'].' limit 1')
                ->result_array();
            $data['next_article'] = $this->db
                ->query('select * from t_article where articleid>'.$id.' and classid='.$data['article_info']['classid'].' limit 1')
                ->result_array();

            /*左侧部分，联系我们*/
            $contact_config = $this->m_public->getRowInfo('config',array('configid'=>CONFIG_ID),'contact_config');
            $data['contact'] = json_decode($contact_config['contact_config'],true);

            /*SEO部分*/
            $config = $this->m_public->getRowInfo('config',array('configid'=>CONFIG_ID));
            $data['g_site']['websitename'] = $config['websitename'];
            $data['g_site']['websitekeywords'] = $config['websitekeywords'];
            $data['g_site']['websitedescription'] = $config['websitedescription'];
            if(isset($data['action_info']['seotitle']) && !empty($data['action_info']['seotitle']))
                $data['g_site']['websitename'] = $data['action_info']['seotitle'];
            if(isset($data['action_info']['keywords']) && !empty($data['action_info']['keywords']))
                $data['g_site']['websitekeywords'] = $data['action_info']['keywords'];
            if(isset($data['action_info']['description']) && !empty($data['action_info']['description']))
                $data['g_site']['websitedescription'] = $data['action_info']['description'];

            /*头部,底部数据*/
            $config = $this->m_public->getRowInfo('config',array('configid'=>CONFIG_ID),'copyright,banquan,contact_config,footerinfo');
            $config['contact_config'] = json_decode($config['contact_config'],true);
            $data['config'] = $config;
            $footer_condition = array(
                'from' => 'link',
                'where' => array('isclose'=>0,'typeid'=>1,'configid'=>CONFIG_ID),
                'order' => 'listid'
            );
            $data['footer_info'] = $this->m_public->get_list($footer_condition);

            $this->load->view('article_detail',$data);
        }else{
            redirect('cn/main/nofont');
        }
    }

}
